package cn.shop.dys.util;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import cn.shop.lib_common.CommonUtil;
import cn.shop.dys.R;

/**
 * view处理工具
 * Created by sunjian on 2016/4/16.
 */
public class MyViewUtil {
    public static void initPopupWindow(Context context,View view,View pwView) {
        PopupWindow popupWindow= new PopupWindow(pwView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
        popupWindow.setBackgroundDrawable(new ColorDrawable());
        popupWindow.setAnimationStyle(R.style.PopupWindowAnimation);
        int[] location = new int[2];
        view.getLocationInWindow(location);
        popupWindow.showAsDropDown(view, (int) -CommonUtil.dpToPx(context, 80), (int) -CommonUtil.dpToPx(context, 10));
        //  popupWindow.showAtLocation(view, Gravity.RIGHT| Gravity.TOP, location[0]+40, location[1] + 40);
    }
}
